package net.lgy.config;


import io.minio.MinioClient;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Data
@Component
@ConfigurationProperties(prefix = "minio")
public class MinioConfig {

    @Value("endpoint")
    public String endpoint;

    @Value("access-key")
    public String accessKey;

    @Value("access-secret")
    public String accessSecret;

    @Value("bucket-name")
    public String bucketName;

    @Value("avatar-bucket-name")
    public String avatarBucketName;

    // 预签名url过期时间(ms)
//    临时访问url的过期时间
    private Long PRE_SIGN_URL_EXPIRE = 60 * 10 * 1000L;

    @Bean
    public MinioClient getMinioClient() {
        return MinioClient.builder()
                .endpoint(endpoint)
                .credentials(accessKey, accessSecret)
                .build();
    }
}
